module.exports = function (fastify) {
  fastify.addHook("onRequest", (request, reply, done) => {
    console.log(request.body);
    console.log(request.query);
    console.log(request.params);
    console.log(request.headers);
    console.log(request.raw);
    console.log(request.server);
    console.log(request.id);
    console.log(request.ip);
    console.log(request.ips);
    console.log(request.hostname);
    console.log(request.protocol);
    request.log.info("some info");
    done();
  });
  fastify.addHook("preValidation", (req, reply, done) => {
    // req.body = { ...req.body, importantKey: "randomString" };
    done();
  });
  fastify.addHook("onError", (request, reply, error, done) => {
    // 其他代码
    done();
  });
  fastify.addHook("onResponse", (request, reply, done) => {
    // 其他代码
    done();
  });
  fastify.addHook("onTimeout", (request, reply, done) => {
    // 其他代码
    done();
  });
  fastify.addHook("preHandler", (request, reply, done) => {
    reply.code(400);
    done(new Error("Some error"));
  });
};
